﻿@using System.Configuration
@using Signum.Web.Properties
@model TypeContext
@{
    ModifiableEntity modifiable = Model.UntypedValue as ModifiableEntity;
    string partialViewName = ViewData[ViewDataKeys.PartialViewName].ToString();
}               
<div>
    @Html.AntiForgeryToken()
    @Html.Hidden(ViewDataKeys.TabId, ViewData[ViewDataKeys.TabId])
    @Html.Hidden(ViewDataKeys.PartialViewName, ViewData[ViewDataKeys.PartialViewName])
    <div class="ui-widget-header ui-corner-all sf-normal-control-header">
        <span class="sf-type-nice-name">@Navigator.Manager.GetTypeTitle(modifiable)</span>
        @Html.RenderWidgetsForEntity(modifiable, partialViewName, Model.ControlID)
    </div>
    <div class="clearall"></div>
    @if(string.IsNullOrEmpty(ViewBag.Title))
    {
        ViewBag.Title = modifiable.TryToString();
    }
    <span class="sf-entity-title">@(ViewBag.Title)</span>
</div>
<div class="sf-button-bar">
    @if (Model != null && Navigator.Manager.ShowSave(modifiable.GetType()) && !Model.ReadOnly)
    {
        <a id="ebSave" class="sf-entity-button sf-save" onclick="new SF.Validator({controllerUrl:'@Url.SignumAction("TrySave")'}).trySave();">@Resources.Save</a>  
    }
    @ButtonBarEntityHelper.GetForEntity(new EntityButtonContext
    { 
        Buttons = ViewButtons.Save,
        ControllerContext = this.ViewContext,
        PartialViewName = ViewData[ViewDataKeys.PartialViewName].ToString(),
        Prefix =  Model.ControlID
    },  (ModifiableEntity)Model.UntypedValue).ToString(Html)
</div>

<div class="clearall"></div>
<div class="validationSummaryAjax">
    @Html.ValidationSummaryAjax()
    @Html.NormalPageHeader()
</div>
<div id="divMainControl" class="sf-main-control" data-prefix="@Model.ControlID">
    @{ Html.RenderPartial(partialViewName, Model);}
</div>
